package com.gabgab.org.common.manager;

import java.text.SimpleDateFormat;
import java.util.Date;

public class LogManager {
    private static LogManager instance;

    private LogManager() {

    }

    public static LogManager getInstance() {
        if(instance == null)
            instance = new LogManager();

        return instance;
    }

    public void logError(String message) {
        this.log(message, "ERROR");
    }

    public void logWarning(String message) {
        this.log(message, "WARNING");
    }

    public void logInfo(String message){
        this.log(message, "INFO");
    }

    private void log(String message, String type){
        StringBuffer logBuffer = new StringBuffer();
        logBuffer.append(this.getTimestamp());
        logBuffer.append(type);
        logBuffer.append(":\t");
        logBuffer.append(message);
        System.out.println(logBuffer);
    }

    private String getTimestamp() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        String timestamp = sdf.format(date);
        return "(" + timestamp + ") ";
    }
}
